package cn.clx.ymcc.feign;


import cn.clx.ymcc.doc.CourseDoc;
import cn.clx.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import javax.validation.Valid;

@Component
public class SearchFeignBallbackFactory implements FallbackFactory<ISearchFeignClient> {

    @Override
    public ISearchFeignClient create(Throwable throwable) {
        return new ISearchFeignClient() {

            @Override
            public JSONResult saveES(@Valid CourseDoc doc) {
                return JSONResult.error("服务不可达，熔断了");
            }

            @Override
            public JSONResult deleteES(Long id) {
                return JSONResult.error("服务不可达，熔断了");
            }
        };
    }
}
